package GUI_Data.Staff;

import GUI_Data.Staff.AllButtonStaff;
import GUI_Data.Staff.AllLabelAndTextFieldStaff;
import GUI_Data.Staff.AllPanelStaff;
import GUI_Data.User.SetDimension;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
 * The user frame.
 * It's the client window, including connect data, initialize interface and reset interface functions.
 * @author Chunxi Lin
 */
public class Staff extends JFrame implements ActionListener, FocusListener {
    private CardLayout frameCard = new CardLayout();
    private JPanel contentPanel = new JPanel(frameCard);

    /**
     * The generator of the staff frame.
     */
    public Staff() {
        initStaff();

        setResizable(false);
        setUndecorated(true);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    /**
     * The init method of the whole frame.
     * By using the card layout, the page can be refreshed and invoked at frame initialization and page reset
     */
    public void initStaff() {
        JPanel nowFrame = new JPanel();
        contentPanel.add("now frame", nowFrame);
        setContentPane(contentPanel);

        SetDimension dimension = new SetDimension();

        setTitle("Welcome!");
        setExtendedState(MAXIMIZED_BOTH);

        CardLayout card = new CardLayout();
        CardLayout login = new CardLayout();
        CardLayout passenger = new CardLayout();

        // initialize all button
        AllButtonStaff allButton = new AllButtonStaff(this, dimension);
        // initialize all label and text field
        AllLabelAndTextFieldStaff allLabelAndTextField = new AllLabelAndTextFieldStaff(this);

        // initialize all panel
        AllPanelStaff allPanel = new AllPanelStaff(nowFrame, dimension, allButton, allLabelAndTextField, card, login, passenger);
        // initialize the actionListener of all buttons.
        allButton.addActionPerform(this, dimension, allPanel, allLabelAndTextField, card, login, passenger);

        //setBackgroundInfo(dimension);
        frameCard.next(contentPanel);
    }

    @Override
    public void actionPerformed(ActionEvent e) {

    }

    @Override
    public void focusGained(FocusEvent e) {

    }

    @Override
    public void focusLost(FocusEvent e) {

    }
}